<html>
<head><meta charset="utf-8"><title>extracting backtrace data · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/extracting.20backtrace.20data.html">extracting backtrace data</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="197006481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/extracting%20backtrace%20data/near/197006481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> zeroexcuses <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/extracting.20backtrace.20data.html#197006481">(May 09 2020 at 18:55)</a>:</h4>
<p>How do I extract</p>
<div class="codehilite"><pre><span></span><code>struct Capture {
    actual_start: usize,
    resolved: bool,
    frames: Vec&lt;BacktraceFrame&gt;,
}
</code></pre></div>


<p>from <a href="https://doc.rust-lang.org/std/backtrace/struct.Backtrace.html" title="https://doc.rust-lang.org/std/backtrace/struct.Backtrace.html">https://doc.rust-lang.org/std/backtrace/struct.Backtrace.html</a> ?</p>
<p>In particular, I don't want to just print the Backtrace via debug. Instead, I want to run through the backtrace frames and print only a subset.</p>



<a name="197007059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/extracting%20backtrace%20data/near/197007059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mark Drobnak <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/extracting.20backtrace.20data.html#197007059">(May 09 2020 at 19:09)</a>:</h4>
<p><code>Capture</code> is a private type, so you probably can't get that directly. You probably want to use the <a href="https://crates.io/crates/backtrace" title="https://crates.io/crates/backtrace"><code>backtrace</code></a> crate, which has a <a href="https://docs.rs/backtrace/0.3.46/backtrace/struct.Backtrace.html#method.frames" title="https://docs.rs/backtrace/0.3.46/backtrace/struct.Backtrace.html#method.frames"><code>frames</code></a> method and supports stable as well.</p>



<a name="197012333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/extracting%20backtrace%20data/near/197012333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> zeroexcuses <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/extracting.20backtrace.20data.html#197012333">(May 09 2020 at 20:53)</a>:</h4>
<p>Interesting. I (incorrectly) thought crate backtrace-rs was for pre-feature-std::backtrace. I did not realize the two were meant to be used together.</p>



<a name="197043431"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/extracting%20backtrace%20data/near/197043431" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/extracting.20backtrace.20data.html#197043431">(May 10 2020 at 09:08)</a>:</h4>
<p>not sure if "used together" is the right term -- std does not expose that it uses the backtrace crate under the hood</p>



<a name="197043456"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/extracting%20backtrace%20data/near/197043456" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/extracting.20backtrace.20data.html#197043456">(May 10 2020 at 09:08)</a>:</h4>
<p>you can use one or the other, the backend is the same. std will provide very strong stability guarantees once it is stable. the crate API has been refined less and might see breaking changes in the future.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>